package com.androwit.engine.mapping;

public class BasicMappingField<J, K, V> implements MappingField<J, K, V> {

	protected K key;
	protected Converter<J, V> converter;
	protected String name;
	private boolean handledSpecifically;

	public BasicMappingField(K key, Converter<J, V> converter, String name) {
		this(key, converter, name, false);
	}

	public BasicMappingField(K key, Converter<J, V> converter, String name, boolean handledSpecifically) {
		this.key = key;
		this.converter = converter;
		this.name = name;
		this.handledSpecifically = handledSpecifically;
	}

	@Override
	public Converter<J, V> getConverter() {
		return converter;
	}

	/**
	 * returns the key in cassandra
	 * 
	 * @see com.androwit.engine.mapping.MappingField#getKey()
	 */
	@Override
	public K getKey() {
		return key;
	}

	/**
	 * returns the javabean name
	 * 
	 * @see com.androwit.engine.mapping.MappingField#getName()
	 */
	@Override
	public String getName() {
		return name;
	}

	@Override
	public boolean handledSpecifically() {
		return handledSpecifically;
	}

	public void setHandledSpecifically(boolean handledSpecifically) {
		this.handledSpecifically = handledSpecifically;
	}

	@Override
	public String toString() {
		return name + ": key(" + key + "), converter: " + converter;
	}

	public void setConverter(Converter<J, V> converter) {
		this.converter = converter;
	}

}
